package com.xckx.Visio.Xml;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2007</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import java.awt.*;

public class MonitorThrd  extends Thread {
  private Thread     thread;
  private Dialog     dialog;

  public MonitorThrd(Dialog dlg, Thread thrd) {
    thread = thrd;
    dialog = dlg;
  }

  public void run() {
    while (true) {
      if (!thread.isAlive() || thread.isInterrupted()) {
        this.cleanHouse();
        break;
      }
      try {
        this.sleep(200);
      } catch (Exception e) {
        this.cleanHouse();
        break;
      }
    }
  }

  private void cleanHouse() {
    thread.stop();
    if (dialog.isShowing())
      dialog.dispose();
    this.stop();
    this.destroy();
  }
}


